package com.appleyk.node;


import com.appleyk.relation.LikeRelation;
import com.appleyk.relation.Recomm;
import com.fasterxml.jackson.annotation.JsonBackReference;
import org.neo4j.ogm.annotation.GraphId;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Relationship;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @NodeEntity节点类
 */
@NodeEntity
public class Tuser implements Serializable{

    /**
     * 序列化ID
     */
    private static final long serialVersionUID = -7869658507417599556L;

    /**
     * 节点ID
     */
    @GraphId
    private Long id;

    /**
     * 节点的name
     */
    protected String name;


    public String getName() {
        return name;
    }


    public Tuser setName(String name) {
        this.name = name;
        return this;
    }

    /**
     * 小程序配置的 用户TID
     */
    private Long uid;

    /**
     * 用户性别
     */
    private String sex;



    /**
     * 用户年龄
     */
    private Integer age;

    /**
     * 兴趣爱好
     */
    private List<String> hobbies;
    /**
     * 评价
     */
    private String pijia="等待评价";

    /**
     *
     * 添加关系喜欢，方向为  ->，表明当前节点是startNode(开始节点 前驱节点)
     * type =关系类型 对应数据库表   direction 指向(方向) 外向的(下行)
     */

    @Relationship(type="Recomm",direction = Relationship.OUTGOING)
    private List<Recomm> likes;



    public String getPijia() {
        return pijia;
    }

    public Tuser setPijia(String pijia) {
        this.pijia = pijia;
        return this;
    }

    public Tuser(){
        /**
         * 当城建对象
         */
        this.hobbies=new ArrayList<>();
        this.likes=new ArrayList<>();
    }

    /**
     * 方便测试 添加的ADD方法写入
     * @param tuser
     */
    public void add(Tuser tuser){
        Recomm recomm=new Recomm(this,tuser);
        likes.add(recomm);
    }
    public void addHobbies(String str){
        hobbies.add(str);
    }

    public Long getUid() {
        return uid;
    }

    public Tuser setUid(Long uid) {
        this.uid = uid;
        return this;
    }

    public String getSex() {
        return sex;
    }

    public Tuser setSex(String sex) {
        this.sex = sex;
        return this;
    }

    public Integer getAge() {
        return age;
    }

    public Tuser setAge(Integer age) {
        this.age = age;
        return this;
    }

    public List<String> getHobbies() {
        return hobbies;
    }

    public Tuser setHobbies(List<String> hobbies) {
        this.hobbies = hobbies;
        return this;
    }

    /**
     *  @JsonBackReference该注解 在解析Json时候  不展示 该属性  不添加该注解将 无线循环
     * @return
     */
    @JsonBackReference
    public List<Recomm> getLikes() {
        return likes;
    }



    public Tuser setLikes(List<Recomm> likes) {
        this.likes = likes;
        return this;
    }
}
